<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<style>
    .layui-table tr td .laytp-tree-table-cell > .laytp-tree-table-cell-content{
        font-size: 13px;
    }
</style>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">月份</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="month" id="month" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_one_ym">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>

    var date = new Date()
    var year = date.getFullYear()
    var month = date.getMonth() + 1
    if(month < 10){
        month = '0'+month
    }
    var monthValue = year+'-'+month;
    $("#month").val(monthValue);


    var mytable, form;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable', 'treeTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable, treeTable=layui.treeTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });


        setSouTableExport('人员流动情况表', 2);
        mytable = treeTable.render({
            elem: "#datalist",
            id: "datalist",
            title: "人员流动情况表",
            url: facade.url(ask_human_count_renliu),
            where: {month:monthValue},
            page: false,
            height: 'full-140',
            soulSort: TabInit.soulSort,
            method: TabInit.method,
            toolbar: TabInit.toolbar,
            overflow: TabInit.overflow,
            defaultToolbar: TabInit.defaultToolbar,
            filter: TabInit.filter,
            request: TabInit.request,
            response: TabInit.response,
            contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text
            , tree: {
                iconIndex: 1        // 折叠图标显示在第几列
                , arrowType: 'arrow2'   // 自定义箭头风格
                , getIcon: function (d) {  // 自定义图标
                    // d是当前行的数据
                    if (d.children && d.children.length > 0) {  // 判断是否有子集
                        return '<i class="laytp-tree-icon laytp-tree-icon-folder"></i>';
                    } else {
                        return '<i class="laytp-tree-icon laytp-tree-icon-file"></i>';
                    }
                }
            }
            ,parseData: function (res) {
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.total,
                    "data": res.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{field: 'name', title: '部门名称',width:300}
                ,{field: 'allnum', title: '员工数'}
                ,{field: 'yue_ru', title: '本月入职'}
                ,{field: 'yue_out', title: '本月离职'}
                ,{field: 'year_ru', title: '年度累计入职'}
                ,{field: 'year_out', title: '年度累计离职'}
            ]]
            , done: function (res) {
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
            }
        });

        listTableSearch(form, table);
    });






    function searchTableFunc(form, table) {
        var data = form.val('TableSearchForm');
        mytable.reload('datalist', {
            where: data
        });
    }


</script>
</body>
</html>
